#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QFileDialog>
#include <QLabel>
#include <QStandardItemModel>
#include <QStandardItem>
#include <QTreeWidgetItem>
#include <QToolBar>
#include "description.h"
#include "rs232.h"
#include "ethernet.h"
#include "virtualdevice.h"
#include "jakarobot.h"
#include "delay.h"
#include "wordopcontrolled.h"
#include "movejoint.h"
#include "snap.h"
#include "recognize.h"
#include "step.h"
#include "newdevicedialog.h"
#include "newoperationdialog.h"
#include "testalldevicethread.h"
#include "rundescriptionthread.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    QToolBar        *m_pToolBar{nullptr};
    QLabel          *m_labelInformation;
    Description     m_description;

    QString         m_strXMLFilename;
    QStandardItem   *m_pCurrentItem;
    QModelIndex     m_nCurrentIndex;
    TestAllDeviceThread m_TestAllDeviceThread;
    RunDescriptionThread* m_RunDescriptionThread;

private slots:
    void OpenXMLFile();
    void SaveXMLFile();
    void RunXMLFile();
    void TestXMLFile();
    void on_image_tree_currentChanged(const QModelIndex& current);
    void slotActionTriggered(const QPoint& pos);
    void slotTreeMenuNew();

    void on_comboBoxSerialPortName_currentIndexChanged(int index);

    void on_comboBoxSerialPortBaud_currentIndexChanged(int index);

    void on_comboBoxSerialPortDataBits_currentIndexChanged(int index);

    void on_comboBoxSerialPortParity_currentIndexChanged(int index);

    void on_comboBoxSerialPortStopBits_currentIndexChanged(int index);

    void on_lineEditRS232DeviceID_editingFinished();

    void on_lineEditEthernetID_editingFinished();

    void on_lineEditEthernetIP_editingFinished();

    void on_lineEditEthernetPort_editingFinished();

    void on_lineEditDuration_editingFinished();

    void on_lineEditCameraDeviceID_editingFinished();

    void on_comboBoxLEDChannel_currentIndexChanged(int index);

    void on_lineEditLEDValue_editingFinished();

    void on_lineEditWordopControlLEDDeviceID_editingFinished();

    void on_lineEditMoveJoint1_editingFinished();

    void on_lineEditMoveJoint2_editingFinished();

    void on_lineEditMoveJoint3_editingFinished();

    void on_lineEditMoveJoint4_editingFinished();

    void on_lineEditMoveJoint5_editingFinished();

    void on_lineEditMoveJoint6_editingFinished();

    void on_lineEditMoveJointDeviceID_editingFinished();

    void on_lineEditStep_editingFinished();

    void on_lineEditSnapImage_editingFinished();

    void on_lineEditRecognizeImage_editingFinished();

    void on_lineEditJakaRobotIP_editingFinished();

    void on_lineEditJakaRobotPort_editingFinished();

    void on_lineEditJakaRobotDeviceID_editingFinished();

    void on_lineEditRecognizeDeviceID_editingFinished();

    void on_lineEditVirtualDeviceID_editingFinished();

private:
    void insterTreeNode(QString str,QStandardItem *parent);
    void InitTreeView();

private:
    void InitSerialPortNameComboBox();
    void InitSerialPortBaudComboBox();
    void InitSerialPortDataBitsComboBox();
    void InitSerialPortParityComboBox();
    void InitSerialPortStopBitsComboBox();
    void InitWordopControlLEDChannel();
    void InitStepComboBox();

    void UpdateRS232Data(RS232* pRS232);
    void UpdateEthernetData(Ethernet* pEthernet);
    void UpdateJakaRobotData(JakaRobot* pJakaRobot);
    void UpdateVirtualDeviceData(VirtualDevice* pVirtualDevice);
    void UpdateDelayData(Delay* pDelay);
    void UpdateWordopControlLEDData(WordopControlLED* pWordopControlLEDData);
    void UpdateSnapData(Snap* pSnap);
    void UpdateRecognizeData(Recognize* pRecognize);
    void UpdateMoveJointData(MoveJoint* pMoveJoint);
    void UpdateStepData(Step* pStep);

private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
